package com.example.boot_6;


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.stream.IntStream;

/***
 * 大小写转换
 */
public class TestByMy {
    public static void main(String[] args) {
        String s = "SSSSZaasdfsdafFDSF";
        char[] cc = s.toCharArray();
        IntStream.range(0,cc.length).forEach(i ->{
            if (cc[i]>95){
                cc[i]-=32;
            }else {
                cc[i]+=32;
            }
        });
        System.out.println(cc);

        ByteArrayInputStream ss = new ByteArrayInputStream(s.getBytes());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int b = -1;
        while((b = ss.read()) != -1){
            //把大写字母转换成小写字母
            if(b >= 97 && b <= 122){ //大写字母从 65~90, 小写字母从 97~122
                b -= 32;
            }else {
                b+=32;
            }
            //写回到字节数组输出流中
            baos.write(b);
        }
        //输出，并把字节数组输出流转换成字符串
        String out = baos.toString();
        System.out.println(out);
        char c = s.charAt(2);
        System.out.println(c);
        String s1 = s.toUpperCase();
        System.out.println(s1);

    }

}
